package com.yifushidai.api;

import com.alibaba.fastjson.JSON;
import com.yifushidai.entity.RoomManagementEntity;
import com.yifushidai.service.RoomManagementService;
import com.yifushidai.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api(tags = "家电功率")
@RequestMapping("/api/roommanagement")
public class RoomManagementController {

    @Autowired
    private RoomManagementService roomManagementService;

    @PostMapping("/saveOrUpdate")
    @ApiOperation(value = "保存或更新")
    public R saveOrUpdate(@ApiParam(value = "联网盒mac", required = true) @RequestParam String mac,
                          @ApiParam(value = "JSON参数", required = true) @RequestParam String param) throws Exception {
        return roomManagementService.saveAfterDelete(mac, param);
    }

    @PostMapping("/queryList")
    @ApiOperation(value = "查询列表")
    public R queryList(@ApiParam(value = "联网盒mac", required = true) @RequestParam String mac) throws Exception {
        return roomManagementService.queryListByMac(mac);
    }

}
